Ronan - Tuesday, November 23, 2010 10:49 AM:
Hello,
I'm trying to launch a server process when a certain type of file is added to the vault. I bound a C# method to the onAfterAdd event of the File ItemType, which does something like this:
string fileId = this.getProperty("id");
string inFilename = this.getProperty("filename");
// having the id determines the final vault URL (thanks Brian for this post)
string vaultDir = "C:\Aras\Vault\InnovatorSolutions";
string inURL = vaultDir + "\" + fileId.Substring(0, 1) + "\" + fileId.Substring(1, 2) + "\" + fileId.Substring(3, 29) + "\" + inFilename;
string outURL = "C:\conv\out_" + inFilename;
string converterExe = "C:\conv\conv.exe";
string converterParams = "-i " + inURL + " -o " + outURL;
// nevermind Process.Start isn't the best way to start a process
System.Diagnostics.Process.Start(converterExe, converterParams);
Now, my problem is that even when using onAfterAdd, the uploaded file doesn't exist yet in the vault when my method runs. The addition to the vault is done right after my method ends (I can see the file correctly popping on Windows Explorer server side at "inURL").
Does anybody see a clean way to do this? I can see several more or less dirty workarounds, in Aras (firing an async method using a timer) or via Windows programming (monitoring the vault), but I'd prefer to do it properly via an event that meets my needs...
Thanks for your help.
Brian - Saturday, November 27, 2010 5:43 AM:
Hi Ronan,
You could write a windows service that you signal when the files are added and have it do the work or have it run a method in Innovator. That way you can be sure the file is there.
Cheers,
Brian.